<template>
    <v-md-editor v-model="text"
                 height="100%"
                 :codemirrorConfig="codemirrorConfig"
                 @upload-image="handleUploadImage"
                 :disabled-menus="[]">
    </v-md-editor>
</template>

<script lang="ts">
export default {
    data() {
        return {
            text: '',
            codemirrorConfig: {
                tabSize: 4,//tab大小
                lineNumbers: true,//编辑器行号
                line: true,
            }
        };
    },
    methods: {
        handleUploadImage(event, insertImage, files) {
            console.log(event, insertImage, files)
            let fileReader = new FileReader()
            let image = files[0] || null
            fileReader.readAsDataURL(image)
            fileReader.addEventListener('load', (e) => {
                insertImage({
                    url: e.target!.result
                })
            })
        }
    }
};
</script>
<style scoped>

</style>
